package com.example.redis.dao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Repository;

@Repository
public class RedisDao {

    private final StringRedisTemplate template;

    @Autowired
    public RedisDao(StringRedisTemplate template) {
        this.template = template;
    }

    public void setKey(String key, String value) {
        template.opsForValue().set(key, value);
    }

    public String getValue(String key) {
        return template.opsForValue().get(key);
    }
}